!(function(global, userUtil, layer, dataUtil) {

	//申请记录
	getborrowingInfo();
    var orderNo ;
  	var stateConf = {
	      1: { text: "申请中", operateTxt: "继续提交" },
	      2: { text: "审核中", operateTxt: "审核中" },
	      3: { text: "复审中", operateTxt: "复审中" },
	      4: { text: "待放款", operateTxt: "待放款" },
	      5: { text: "待还款", operateTxt: "一键还款" },
	      6: { text: "已还款", operateTxt: "再次申请" },
	      7: { text: "审核不通过", operateTxt: "再次申请"},
	      8: { text: "逾期待还款", operateTxt: "一键还款" },
	      9: { text: "逾期已还款", operateTxt: "再次申请" },
	      10: { text: "复审拒绝", operateTxt: "复审拒绝" },
	      11: { text: "还款处理中", operateTxt: "还款处理中" },
	      12: { text: "放款失败", operateTxt: "放款失败" },      
  	};
	function getborrowingInfo() {
		userUtil.ajax({
			url: global.localUrl + 'orders/borrowingInfo',
			data: {},
			done: function(re) {
				//layer.hideLoad();
				var $dom;
				if(re.data == 0) {
					$("#borrowList").html("<div class='orderNone'>暂无订单</div>");

				}
				$.each(re.data, function(k, v) {
					orderNo = v.orderNo;
					if(v.status == 1 || v.status == 5 || (v.status == 7 && v.orderRemark == "") || v.status == 8) { //有操作按钮
			             $dom = '<div class="recordContent">'
							+'<div class="recordListTop">'   
							+'<div class="recordListLeft">'
							+'<dl class="repayInfons">'
							+'<dt class=" titleLeft"><i class="showNum">借款金额(元)</i></dt>'
							+'<dd class="titleContentLeft">'+v.borrowingAmount+'</dd></dl>'    		
							+'<dl class="repayInfons">'
							+'<dt class="titleRight"><i class="showNum">借款期限(天)</i></dt>'
							+'<dd class="titleContentRight">'+v.borrowingTerm.substring(0,1)+'</dd></dl></div>'
							+'<div class="recordListLeft">'
							+'<dl class="repayInfons">'
							+'<dt class=" titleLeft"><i class="showNum">已还金额(元)</i></dt>'
							+'<dd class="titleContentLeft">'+v.areadyRepay+'</dd></dl>'    		
							+'<dl class="repayInfons">'
							+'<dt class="titleRight"><i class="showNum">应还金额(元)</i></dt>'
							+'<dd class="titleContentRight">'+v.paybackTotalAmount+'</dd></dl></div></div>'
							+'<div class="recordListBottom">'
							+'<ul class="tipsInfo">'
							+'<li>申请时间：<span>'+v.createTime+'</span></li>'
							+'<li>申请编号：<span>'+v.orderNo+'</span></li>'
							+'<li>还款截止时间：<span>还款日下午4点</span></li>'
							+'<li>订单状态：<span>'+stateConf[v.status].text+'</span></li></ul>'
							+'<div class="recordListRight recordListBtnBottom1">'   
							+'<a data-status='+v.status+' id="fastRepay" class="fastRepay">'+stateConf[v.status].operateTxt+'</a>'
							+'<a data-status='+v.status+' class="halfFastRepay" style="visibility:hidden;">部分还款</a>'
							+'</div></div>'
							+'<span class="cirlLeft"></span><span class="cirlRight"></span></div>'
					} else {
		                $dom = '<div class="recordContent">'
							+'<div class="recordListTop">'   
							+'<div class="recordListLeft">'
							+'<dl class="repayInfons">'
							+'<dt class=" titleLeft"><i class="showNum">借款金额(元)</i></dt>'
							+'<dd class="titleContentLeft">'+v.borrowingAmount+'</dd></dl>'    		
							+'<dl class="repayInfons">'
							+'<dt class="titleRight"><i class="showNum">借款期限(天)</i></dt>'
							+'<dd class="titleContentRight">'+v.borrowingTerm.substring(0,1)+'</dd></dl></div>'
							+'<div class="recordListLeft">'
							+'<dl class="repayInfons">'
							+'<dt class=" titleLeft"><i class="showNum">已还金额(元)</i></dt>'
							+'<dd class="titleContentLeft">'+v.areadyRepay+'</dd></dl>'    		
							+'<dl class="repayInfons">'
							+'<dt class="titleRight"><i class="showNum">应还金额(元)</i></dt>'
							+'<dd class="titleContentRight">'+v.paybackTotalAmount+'</dd></dl></div></div>'
							+'<div class="recordListBottom">'
							+'<ul class="tipsInfo">'
							+'<li>申请时间：<span>'+v.createTime+'</span></li>'
							+'<li>申请编号：<span>'+v.orderNo+'</span></li>'
							+'<li>还款截止时间：<span>还款日下午4点</span></li>'
							+'<li>订单状态：<span>'+stateConf[v.status].text+'</span></li></ul>'
							+'<div class="recordListRight recordListBtnBottom">' 
							+'<a data-status='+v.status+' id="fastRepay" class="fastRepay">'+stateConf[v.status].operateTxt+'</a></div></div>'
							+'<span class="cirlLeft"></span><span class="cirlRight"></span></div>'
					}
					$("#borrowList").append($dom);

		            if(v.status == 1){
		            	$('.recordListBtnBottom1 a').addClass('Reapplay');
		            	$('.recordListBtnBottom1 a').attr('href','../trust/identification.html');
		            	$('.tipsImg1').css("opacity","0");
		            }else if(v.status == 2 || v.status == 3 || v.status == 4){
		            	$('.recordListBtnBottom a').removeClass('fastRepay').addClass('unopreat');
		            }else if(v.status == 5||v.status == 8){
		            	$('.halfFastRepay').css('visibility','visible');
		            	$('.recordListBtnBottom1 .fastRepay').attr('href','repaymentDetail.html?orderNo='+orderNo);
		            	$('.recordListBtnBottom1 .halfFastRepay').attr('href','halfRepaymentDetail.html?orderNo='+orderNo);
		            }else if(v.status == 7&&v.orderRemark !=""){
		            	$('.recordListBtnBottom a').addClass('Reapplay');
		            	$('.recordListBtnBottom a').attr('href','../index.html');
		            }else if(v.status == 6 ||v.status == 9){
		            	$('.recordListBtnBottom a').addClass('repayFast');
		            	$('.recordListBtnBottom a').attr('href','../index.html');		            	
		            }else if(v.status == 10 ||v.status == 11){
		            	$('.recordListBtnBottom a').removeClass('fastRepay').addClass('unopreat');		            	
		            }else if(v.status == 12){
		            	$('.recordListBtnBottom a').removeClass('fastRepay').addClass('unopreat');           	
		            }
		            if(v.areadyRepay > 0){
						$('#fastRepay').attr('href','javascript:;');
						layer.tips('您目前正在使用部分还款');
					}
				});

//				$('.recordListBtnBottom a').on("click", function() {
//					var _this = $(this);
//					if(_this.attr("data-status") == 1) {
//						window.location.href = "../trust/identification.html";
//					} else if(_this.attr("data-status") == 5) {
//						window.location.href = "repaymentDetail.html?orderNo=" + _this.attr("data-uuid");
//					} else if(_this.attr("data-status") == 7) {
//						window.location.href = "../trust/identification.html";
//					} else if(_this.attr("data-status") == 8) {
//						window.location.href = "repaymentDetail.html?orderNo=" + _this.attr("data-uuid");
//					}
//				});

			}
		})
	}

})(global, userUtil, layer, dataUtil)